package com.smasher.domain.fragment

import android.app.Dialog
import android.content.DialogInterface.OnClickListener
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import com.smasher.domain.R

class DeleteDialog : DialogFragment() {

    private var positiveListener: OnClickListener? = null
    private var negativeListener: OnClickListener? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setStyle(STYLE_NO_TITLE, 0)
    }

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        return AlertDialog.Builder(requireContext())
            .setTitle(getString(R.string.delete_domain_title))
            .setMessage(getString(R.string.delete_domain_message))
            .setPositiveButton(getString(R.string.delete_domain_positive), positiveListener)
            .setNegativeButton(getString(R.string.delete_domain_negative), negativeListener)
            .create()
    }

    fun setPositiveListener(positiveListener: OnClickListener) {
        this.positiveListener = positiveListener
    }

    fun setNegativeListener(negativeListener: OnClickListener) {
        this.negativeListener = negativeListener
    }

    companion object {
        const val TAG = "DELETE"

        @JvmStatic
        fun newInstance() =
            DeleteDialog().apply {
                arguments = Bundle()
            }

    }
}
